const util = require('../../utils/util.js');
var app = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    id:'',
    userInfo:'',
    count:'',
    isOpen: false,
    relationUrl:'',
    isBtn:false,
    orUrl:'',
  },
  //返回按钮
  returnBtn(){
    wx.navigateBack({
      delta: 1
    })
  },
  //详情
  getDetails() {
    var that = this
    app.req({
      url: "wechat/birthManage/blessingDetail",
      method: "post",
      data: {
        id: that.data.id
      },
      success: function (res) {
        if (200 == res.code) {
          console.log("生日", res)
          that.setData({
            orUrl: res.data.orUrl,
            birthdayPerson: res.data.birthdayPerson,
            relationUrl: res.data.relationUrl,
            count: res.data.count,
            isBtn:true,
          })
          console.log(that.data.orUrl)
        }
      }
    })
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.setData({
      id:options.id
    })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    var that = this
    app.getUserInfo(function (userInfo) {
      that.setData({
        userInfo: userInfo
      })
    })
    console.log(that.data.userInfo)
    that.getDetails()
  },
  onShareAppMessage: function () {
    var that = this
    app.req({
      url: 'wechat/activity/share',
      data: {
        id: that.data.id,
        type: 2,
      },
      method: 'POST',
      success: function (res) {
        console.log('分享数量', res);
      }
    })
    if(that.data.isBtn){
      that.setData({
        isOpen: true,
      })
        return {
          title: '祝' + that.data.birthdayPerson + '生日快乐！',
          path: '/pages/partySettingMemo/partySettingMemo?id=' + that.data.id,
          success(e) {
            console.log("分享成功了")
          },
          fail(e) {
            console.log("分享失败")
          }
        }
    }
  }
})